home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Comms & Internet / LinkConverter 1.1.2 / Dialog Director v0.7 / Examples / PPPalette.as < prev    next >
Encoding:
Text File  |  1998-01-12  |  2.6 KB  |  63 lines  |  [TEXT/ToyS]

  1. property kRANoError : 0
  2. property kRAPortBusy : -7114
  3. property OpenDialog : {size:[260, 200], style:movable dialog, name:"Open PPP Connection", contents:[¬
  4.     {class:push button, bounds:[190, 170, 250, 190], name:"OK", enabled:[dAnd, 3, 4, 5]}, ¬
  5.     {class:push button, bounds:[110, 170, 170, 190], name:"Cancel"}, ¬
  6.     {class:text field, bounds:[10, 32, 250, 32 + 16], name bounds:¬
  7.         [10, 10, 250, 26], name:"User name:", value:""}, ¬
  8.     {class:password field, bounds:[10, 82, 250, 82 + 16], name bounds:¬
  9.         [10, 60, 250, 76], name:"Password:", value:""}, ¬
  10.     {class:text field, bounds:[10, 132, 250, 132 + 16], name bounds:¬
  11.         [10, 110, 250, 126], name:"Telephone number:", value:""} ¬
  12.         ], timeout after:60}
  13. property mainDialog : {size:[88, 76], name:"PPP", style:standard palette, default item:0, closeable:true, contents:[¬
  14.     {class:push button, bounds:[2, 2, 32, 22], name:"Open", font:5}, ¬
  15.     {class:push button, bounds:[34, 2, 64, 22], name:"Close", font:5}, ¬
  16.     {class:static text, contents:"", bounds:[30, 26, 88, 76], font:5}, ¬
  17.     {class:static text, contents:"time:
  18. in:
  19. out:
  20. msg:", bounds:[4, 26, 30, 76], font:5}]}
  21.  
  22. global username, password, telephone
  23.  
  24. -- a run message is sent to the script application when it is launched.
  25. on run
  26.     dd install with fonts [null, null, null, null, {size:9, name:"Geneva"}] float above every application with grayscale
  27.     set [oked, canceled, username, password, telephone] to dd auto dialog OpenDialog --with greyscale
  28.     --set [oked, canceled, username, password, telephone] to [false, false, "", "", ""]
  29.     if oked then OpenPPP()
  30.     set d to dd make dialog mainDialog
  31.     try
  32.         repeat
  33.             set stat to PPP status
  34.             get stat's state = "connected" --dd set enabled of item 2 of d to stat's state = "connected"
  35.             dd set enabled of items 1 thru 2 of d to [not result, result]
  36.             tell stat to dd set contents of item 3 of d to (seconds connected as string) & return & bytes in & return & bytes out & return & message
  37.             set i to dd interact with user for max ticks 120
  38.             if i = 1 then
  39.                 OpenPPP()
  40.             else if i = 2 then
  41.                 if (PPP status)'s state = "connected" then PPP disconnect
  42.             else if i = -1 then
  43.                 exit repeat
  44.             end if
  45.         end repeat
  46.     on error
  47.     end try
  48.     dd uninstall
  49.     [oked, canceled, username, password, telephone]
  50. end run
  51.  
  52. on OpenPPP()
  53.     try
  54.         if (username ≠ "") then
  55.             PPP connect address telephone user name (username) password (|password|)
  56.         else
  57.             PPP connect address telephone -- guest access
  58.         end if
  59.     on error errmsg number errnum
  60.         if (errnum ≠ kRANoError) and (errnum ≠ kRAPortBusy) then ¬
  61.             display dialog "Error " & errnum & " was encountered when attempting to establish a PPP connection."
  62.     end try
  63. end OpenPPP